package com.kantboot.functional.im.domain.entity;

import com.kantboot.util.core.jpa.KantbootGenerationType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.util.Date;

/**
 * 发送消息的中间件
 */
@Table(name="functional_im_push_message_broker")
@Entity
@Getter
@Setter
@Accessors(chain = true)
@EntityListeners(AuditingEntityListener.class)
public class FunctionalImPushMessageBroker implements Serializable {

    /**
     * 主键
     */
    @Id
    @GenericGenerator(name = "snowflakeId",strategy = KantbootGenerationType.SNOWFLAKE)
    @GeneratedValue(generator = "snowflakeId")
    @Column(name = "id")
    private Long id;

    /**
     * 中间件编码
     */
    @Column(name = "t_code")
    private String code;

    /**
     * 绑定消息
     */
    @Column(name = "message_id")
    private Long messageId;

    /**
     * cid
     */
    @Column(name = "cid")
    private String cid;

    /**
     * 1.未发送 notSend
     * 2.发送中 sending
     * 3.发送成功 sendSuccess
     * 4.发送失败 sendFail
     * 5.未被接收 notReceived
     * 6.已被接收 received
     */
    @Column(name = "t_status_code")
    private String statusCode;

    /**
     * 发送失败原因编码
     */
    @Column(name = "t_status_fail_reason_code")
    private String statusFailReasonCode;

    /**
     * 创建时间
     */
    @CreatedDate
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "gmt_create")
    private Date gmtCreate;

    /**
     * 修改时间
     */
    @LastModifiedDate
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "gmt_modified")
    private Date gmtModified;

}
